
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="../assets/images/favicon.png">
    <title>Material Pro Admin Template - The Most Complete & Trusted Bootstrap 4 Admin Template</title>
    <!-- Bootstrap Core CSS -->
    <link href="../assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="css/colors/blue.css" id="theme" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body class="fix-header fix-sidebar card-no-border">
   	<header>
   		
   	</header>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
      
        <!-- ============================================================== -->
        <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <aside class="left-sidebar">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar">
                <!-- Sidebar navigation-->
                <nav class="sidebar-nav">
                <ul id="sidebarnav">
                	<li><img src="images/xiao.gif" height="200" width="200"></li>
                           <li> <a class="waves-effect waves-dark" href="mycommentList.php" aria-expanded="false"><i class="mdi mdi-gauge"></i><span class="hide-menu">留言</span></a>
                        </li>
                        <li> <a class="waves-effect waves-dark" href="index.php" aria-expanded="false"><i class="mdi mdi-account-check"></i><span class="hide-menu">返回主页</span></a>
                        </li>
                        
                    </ul>
                   
                </nav>
                <!-- End Sidebar navigation -->
            </div>
            <!-- End Sidebar scroll-->
            <!-- Bottom points-->
            <div class="sidebar-footer">
                <!-- item--><a href="" class="link" data-toggle="tooltip" title="Settings"><i class="ti-settings"></i></a>
                <!-- item--><a href="" class="link" data-toggle="tooltip" title="Email"><i class="mdi mdi-gmail"></i></a>
                <!-- item--><a href="" class="link" data-toggle="tooltip" title="Logout"><i class="mdi mdi-power"></i></a> </div>
            <!-- End Bottom points-->
        </aside>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Bread crumb and right sidebar toggle -->
                <!-- ============================================================== -->
                <div class="row page-titles">
                    <div class="col-md-5 col-8 align-self-center">
                        <h3 class="text-themecolor m-b-0 m-t-0">留言</h3>
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                            <li class="breadcrumb-item active">列表</li>
                        </ol>
                    </div>
                    
                </div>
                <!-- ============================================================== -->
                <!-- End Bread crumb and right sidebar toggle -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-block">
                               
                               <?php 
//当前的页号$page，未传参数的情况下，默认第1页
//$vid = $_GET['vid'];  //接收userList.php页面传来的待修改用户的uid参数
//连接数据库
mysql_connect("localhost","root","1161105403");
   mysql_select_db("neuvideo");
   mysql_query("set names utf8");
if (!isset($_GET["page"])) {
  $page=1;
}else{
    $page=$_GET["page"];
}
//每页显示多少条记录$rowsperpage
$rowsperpage=8;
//总共有多少条记录$totalrows
	$sql="select * from comments";
	if($_GET['key']){    //如果根据用户名搜索，需要修改sql语句
    $key = trim($_GET['key']);
    $sql = $sql." where content like '%{$key}%' ";    
    }       
    $result = mysql_query($sql) or die('查询失败！'.mysql_error()); 
    $totalrows=mysql_num_rows($result);//$num记录了结果集中的结果条数
    if ($totalrows==0) {
    	echo "没有找到记录";
    	exit;
    }
  //共分了多少页$totalpages，总记录数除以每页记录数后向上取整
  if($totalrows%$rowsperpage==0)
    $totalpages=$totalrows/$rowsperpage;
  else{
    $totalpages=ceil($totalrows/$rowsperpage);
  }
 //每页的起始记录编号$start 
$start=($page-1)*$rowsperpage;
?>

<!--搜索功能的表单-->
<form  action="">
 
  <input type="text" name="key" placeholder="留言内容或关键字...">
  <input type="submit" value="搜索">  
 </form> 

<!--存储用户信息列表的表格-->
<table class = "table">

 <tr>
  <th>序号</th>
  
	<th>留言内容</th>
	
    <th>发表时间</th>
	<th>操作</th>
 </tr>
 <?php
 	
require_once('dbConn.php');
connect();
 $sql=$sql." limit $start,$rowsperpage"; //编写获取当前页面包含记录的sql语句
 $result=mysql_query($sql);
 $i=1;
  while($row = mysql_fetch_assoc($result))
  {
  ?>
  
<tr>
  <td><?php echo $i++; ?></td>
  
  <td><?php echo $row["content"]; ?></td>
  
  <td><?php echo $row["cdate"]; ?></td>
  	<td style="font-size: large;">
  		<a href = "CommentEdit.php?cid=<?php echo $row["cid"];?>">修改</a>
		<a href = "Commentdelete.php?cid=<?php echo $row["cid"];?>">删除</a></td>
  		</td>
</tr>

 <?php 
   }
 ?> 
</table>
<!--存储分页超链接的表格-->      
<table align="center" width="70%">
 <tr>
  <td colspan="8" align="center">
<?php 
echo "共".$totalrows."条记录 分".$totalpages."页&nbsp;&nbsp;";

//第一种分页显示的形式，首页 尾页 上一页 下一页
//如果不是第1页，则显示第一页和上一页的超链接，否则只显示文字
  if($page>1){
    $first = "<a href=?key={$key}&page=1>首页</a>";
    $pre = "<a href=?key={$key}&page=".($page-1).">上一页</a>";
  }else{
    $first = '首页';
    $pre = '上一页';
  }
  //如果不是最后一页，则显示下一页和最后一页的超链接，否则只显示文字
  if($page<$totalpages){
    $last = "<a href=?key={$key}&page=$totalpages>尾页</a>";
    $next = "<a href=?key={$key}&page=".($page+1).">下一页</a>";
  }else{
    $last = '尾页';
    $next = '下一页';
  }
echo $first."&nbsp;".$pre."&nbsp;";

//第二种分页显示的形式，循环显示第*页超链
for ($i=1; $i <=$totalpages; $i++) { 
echo "<a href=?page=$i&key=$key>第{$i}页</a>&nbsp;";
}

echo $next."&nbsp;".$last."&nbsp;";
 ?> 
 </td>
 
<td>
<!--第3种分页显示的形式，跳转到*页--> 
 <form action="">
 <!--搜索关键字通过隐藏字段传递-->
 <input type="hidden" name="key" value=<?php
  if(isset($_GET["key"]))
      echo $_GET["key"];
  ?>
 

 </form>  
  </td>
</tr>
</table>

                               
                               
                               
                            </div>
                        </div>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <footer class="footer">
        @Welcome to <a href="#">Backstage Management System</a>.......           </footer>
            </footer>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="../assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="../assets/plugins/bootstrap/js/tether.min.js"></script>
    <script src="../assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="../assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>
</body>

</html>
